<!--content-->
<div class="bh-content">
<div class="bh-ly-yw-jipiao-center">
	<div class='t-w'>
		<?php $time = empty($model->departure_time) ? date('Y-m-d') : $model->departure_time;?>
		<div class='t-title-w'>
			<p class='t-title'>
				<span class='t-district'>
				<?php echo Yii::app()->enum->lookUp('district',$model->departure_city)?>
				<?php if ($manner == 'return'):?><span class='fct_tips'></span><?php else:?>→<?php endif;?>
				<?php echo Yii::app()->enum->lookUp('district',$model->landing_city)?></span>
				<span class='t-desc'>对51家航空公司(含代理商)的638个报价进行了比价，筛选出最低价</span>
			</p>
			<div class='bh-clear'></div>
		</div>
		<div class='t-n-w'>
			<div class='t-tab-w <?php if ($manner != 'return') echo 'hide'?>'>
				<ul class='t-tab' id='manner'>
					<li class='hover'>
						<span class='bh-strong'>去程 :</span>
						<span><?php echo Yii::app()->enum->lookUp('district',$model->departure_city)?>到<?php echo Yii::app()->enum->lookUp('district',$model->landing_city)?></span>
						<span class='t-tab-price'>(最低价¥<?php echo intval(
							Ticket::model()->ticketMinPrice(
								$model->departure_city,
								$model->landing_city,
								'',
								'price_dealer')
							)?>)</span>
					</li>
					<li>
						<span class='bh-strong'>返程 :</span>
						<span><?php echo Yii::app()->enum->lookUp('district',$returnModel->departure_city)?>到<?php echo Yii::app()->enum->lookUp('district',$returnModel->landing_city)?></span>
						<span class='t-tab-price'>(最低价¥<?php echo intval(
							Ticket::model()->ticketMinPrice(
								$returnModel->departure_city,
								$returnModel->landing_city,
								'',
								'price_dealer')
							)?>)</span>
					</li>
				</ul>
				<div class='bh-clear'></div>
			</div>
			<ul class='t-n list-time <?php if ($manner == 'return') echo 'hastab'?>' id='oneWay'>
				<?php for ($i=0; $i<=6; $i++):?>
				<li class='<?php 
						if ($time == date('Y-m-d',strtotime("+{$i}day"))) echo 'hover ';
						if ($i == 6) echo 'last';
					?>' val='<?php echo date('Y-m-d',strtotime("+{$i}day"))?>'>
					<p class='t-n-date'><?php echo date('m-d',strtotime("+{$i}day"))?>(<?php echo CUtilHelper::date()->chineseWeek(strtotime("+{$i}day"))?>)</p>
					<p class='t-n-price font-clr'>
						￥<?php echo intval(
							Ticket::model()->ticketMinPrice(
								$model->departure_city,
								$model->landing_city,
								date('Y-m-d',strtotime("+{$i}day")),
								'price_dealer')
							)?>
					</p>
				</li>
				<?php endfor;;?>
			</ul>
			<ul class='t-n list-time <?php if ($manner == 'return') echo 'hastab'?> hide' id='return'>
				<?php for ($i=0; $i<=6; $i++):?>
				<li class='<?php 
						if ($returnModel->departure_time == date('Y-m-d',strtotime("+{$i}day"))) echo 'hover ';
						if ($i == 6) echo 'last';
					?>' val='<?php echo date('Y-m-d',strtotime("+{$i}day"))?>'>
					<p class='t-n-date'><?php echo date('m-d',strtotime("+{$i}day"))?>(<?php echo CUtilHelper::date()->chineseWeek(strtotime("+{$i}day"))?>)</p>
					<p class='t-n-price font-clr'>
						￥<?php echo intval(
							Ticket::model()->ticketMinPrice(
								$returnModel->departure_city,
								$returnModel->landing_city,
								date('Y-m-d',strtotime("+{$i}day")),
								'price_dealer')
							)?>
					</p>
				</li>
				<?php endfor;;?>
			</ul>
			<div class='bh-clear'></div>
		</div>
		<div class ='t-content-w'>
			<div class='t-s-w'>
				<?php $form = $this->beginWidget('CActiveForm', array(
					'method' => 'get',
					'htmlOptions' => array(
						'id' => 'ticket-form',
					),
					'action' => Yii::app()->createUrl('provide/channel/ticketList'),
				))?>
				<?php echo $form->hiddenField($model, 'departure_city',array('id'=>'departure-city'))?>
				<?php echo $form->hiddenField($model, 'landing_city',array('id'=>'landing-city'))?>
				<?php echo $form->hiddenField($model, 'departure_time',array('id'=>'oneWay-time'))?>
				<?php echo $form->hiddenField($returnModel,'landing_city',array('id'=>'return-landing-city'))?>
				<?php echo $form->hiddenField($returnModel,'departure_city',array('id'=>'return-departure-city'))?>
				<?php echo $form->hiddenField($returnModel, 'departure_time',array('id'=>'return-time'))?>
				<?php echo CHtml::hiddenField('manner',$manner,array('id'=>'manner-val'))?>
				<?php echo CHtml::hiddenField('index',empty($_GET['index']) ? 0 : $_GET['index'],array('id' => 'index-val'))?>
					<table>
						<tr>
							<td width=180><a href='#' class='flight_effect flight_time'>起飞时间</a></td>
							<td width=220>航空公司</td>
							<td width=180>价格</td>
						</tr>
					</table>
				<?php $this->endWidget();?>
			</div>
			<div id ='ticket-content'>
				<div class='t-i-w' >
					<!-- 循环 t-i 机票列表 -->
					<?php  foreach ($data->getData() as $one): ?>
					<div class='t-i'>
						<table>
							<tbody>
								<tr>
									<td width=180 class='t-i-district'>
										<p class='t-i-from'><span class='t-i-from-time'><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.departure_time'),'H:i')?></span><?php echo CHtml::value($one, 'profile.departure_airport')?></p>
										<p class='t-i-to'><span class='t-i-to-time'><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.landing_time'),'H:i')?></span><?php echo CHtml::value($one, 'profile.landing_airport')?></p>
									</td>
									<td width=220 class='t-i-plane'>
										<p>
											<?php echo $one->img(18,17)?>
		                    				<?php echo CHtml::value($one, 'profile.airlines')?>
										</p>
										<p class='t-i-plane-type'>机型：<a href='#' class='a-blue d_tgp_a'><?php echo CHtml::value($one, 'profile.aircraft_type')?></a></p>
									</td>
									<td width=180 class='t-i-price'>
										¥<span class='t-i-price-l'><?php echo intval($one->timePriceObjAttr('price_dealer',$time))?></span><span class='t-i-price-r'>-<?php echo intval($one->timePriceObjAttr('price_market',$time)) - intval($one->timePriceObjAttr('price_dealer',$time))?></span>
										<p><span>5.0折</span><span><?php echo Yii::app()->enum->lookUp('goods.flightAccommodation',CHtml::value($one, 'profile.accommodation'))?></span><span><a href='#' class='a-blue d_tgp_a'>退改签</a></span></p>
									</td>
									<td><a href='<?php echo $this->createUrl('ticketWrite',array('id'=>$one->id))?>'>预定</a></td>
								</tr>
	<!--							<tr>-->
	<!--								<td colspan=2>&nbsp;</td>-->
	<!--								<td class='t-i-price'>-->
	<!--									¥<span class='t-i-price-l'>900</span><span class='t-i-price-r'>-50</span>-->
	<!--									<p><span>3.0折</span><span>头等舱</span><span><a href='#' class='a-blue d_tgp_a'>改退签</a></span></p>-->
	<!--								</td>-->
	<!--								<td><a href='#'>预定</a></td>-->
	<!--							</tr>-->
							</tbody>
							<tfoot>
								<tr class='t-i-other'>
									<td>税费：<?php echo CHtml::value($one, 'profile.taxes')?></td>
									<td>飞行时间：<?php echo CUtilHelper::date()->dateDiff(CHtml::value($one, 'profile.landing_time'),CHtml::value($one, 'profile.departure_time'))?></td>
									<td><?php echo CHtml::value($one, 'profile.eat')?></td>
									<td colspan=2>&nbsp;</td>
								</tr>
							</tfoot>
						</table>
					</div>
					<?php endforeach;?>
					<!-- 结束循环t-i -->
				</div>
				<div class='t-i-w' >
					<!-- 循环 t-i 机票列表 -->
					<?php  foreach ($returnData->getData() as $one): ?>
					<div class='t-i'>
						<table>
							<tbody>
								<tr>
									<td width=180 class='t-i-district'>
										<p class='t-i-from'><span class='t-i-from-time'><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.departure_time'),'H:i')?></span><?php echo CHtml::value($one, 'profile.departure_airport')?></p>
										<p class='t-i-to'><span class='t-i-to-time'><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.landing_time'),'H:i')?></span><?php echo CHtml::value($one, 'profile.landing_airport')?></p>
									</td>
									<td width=220 class='t-i-plane'>
										<p>
											<?php echo $one->img(18,17)?>
		                    				<?php echo CHtml::value($one, 'profile.airlines')?>
										</p>
										<p class='t-i-plane-type'>机型：<a href='#' class='a-blue d_tgp_a'><?php echo CHtml::value($one, 'profile.aircraft_type')?></a></p>
									</td>
									<td width=180 class='t-i-price'>
										¥<span class='t-i-price-l'><?php echo intval($one->timePriceObjAttr('price_dealer',$time))?></span><span class='t-i-price-r'>-<?php echo intval($one->timePriceObjAttr('price_market',$time)) - intval($one->timePriceObjAttr('price_dealer',$time))?></span>
										<p><span>5.0折</span><span><?php echo Yii::app()->enum->lookUp('goods.flightAccommodation',CHtml::value($one, 'profile.accommodation'))?></span><span><a href='#' class='a-blue d_tgp_a'>退改签</a></span></p>
									</td>
									<td><a href='<?php echo $this->createUrl('ticketWrite',array('id'=>$one->id))?>'>预定</a></td>
								</tr>
	<!--							<tr>-->
	<!--								<td colspan=2>&nbsp;</td>-->
	<!--								<td class='t-i-price'>-->
	<!--									¥<span class='t-i-price-l'>900</span><span class='t-i-price-r'>-50</span>-->
	<!--									<p><span>3.0折</span><span>头等舱</span><span><a href='#' class='a-blue d_tgp_a'>改退签</a></span></p>-->
	<!--								</td>-->
	<!--								<td><a href='#'>预定</a></td>-->
	<!--							</tr>-->
							</tbody>
							<tfoot>
								<tr class='t-i-other'>
									<td>税费：<?php echo CHtml::value($one, 'profile.taxes')?></td>
									<td>飞行时间：<?php echo CUtilHelper::date()->dateDiff(CHtml::value($one, 'profile.landing_time'),CHtml::value($one, 'profile.departure_time'))?></td>
									<td><?php echo CHtml::value($one, 'profile.eat')?></td>
									<td colspan=2>&nbsp;</td>
								</tr>
							</tfoot>
						</table>
					</div>
					<?php endforeach;?>
					<!-- 结束循环t-i -->
				</div>
			</div>
		</div>
	</div>
</div>

    <div class="bh-ly-yw-jipiao-center">
    	<div class="bh-ly-yw-jipiao-feiji">
        	<span>
        		<a href="#" class="bh-ly-yw-jipiao-cha">查询</a>
        		<a href="#" class="bh-ly-yw-jipiao-yu">预定</a>
        		<a href="#" class="bh-ly-yw-jipiao-yu">付款</a>
        		<a href="#" class="bh-ly-yw-jipiao-yu">完成</a>
        	</span>
        	<?php if (!empty($model->departure_city)&&!empty($model->landing_city)):?>
        		<p><?php echo Yii::app()->enum->lookUp('district',$model->departure_city)?>-<?php echo Yii::app()->enum->lookUp('district',$model->landing_city)?></p>
        	<?php endif;?>
        	<?php echo !empty($model->departure_time) ? $model->departure_time.'出发' : ''?>
        </div>
    	<div class="bh-ly-yw-jipiao-center-xia">
    	
    		<!-- ***************左侧*************** -->
        	<div class="bh-ly-yw-jipiao-center-xialeft bh-fl">
        		<div>
	        		<ul>
						<li>去程：<?php echo Yii::app()->enum->lookUp('district',$model->departure_city)?>-<?php echo Yii::app()->enum->lookUp('district',$model->landing_city)?></li>
						<li>返程：<?php echo Yii::app()->enum->lookUp('district',$model->landing_city)?>-<?php echo Yii::app()->enum->lookUp('district',$model->departure_city)?></li>
					</ul>
	        	</div>
	        	<?php
	    			$form = $this->beginWidget('CActiveForm',array(
					'action' => Yii::app()->controller->createUrl($this->action->id),
					'method' => 'get',
				))?>
            	<div class="bh-ly-yw-jipiao-center-xialeft-top bh-padT10" >
		                        出发城市：<?php echo LyscHtml::citySelector($form, $model, 'departure_city')?>
		                        到达城市：<?php echo LyscHtml::citySelector($form, $model, 'landing_city')?>
		                        出发日期：<?php $this->widget('coms.ui.DataPicker', array(
									'model' => $model,
									'attribute' => 'departure_time',
									'htmlOptions' => array(
										'class' => 'bh-ydxx-input-jj1',
		                        		'id' => 'time',
		                        		'value' => $time
									),
									'options' => array('minDate'=>'%y-%M-%d')
								));?>
                        <span><input type="submit" value="搜索" class="bh-ly-yw-center-jjingqu-sub"/></span>
						<div class="bh-clear"></div>
                </div>
                <div class="bh-ly-yw-jipiao-center-xialeft-bottom">
                	<?php if (!empty($_GET[get_class($model)])):?>
      				<p class="bh-ly-yw-jipiao-center-xialeft-bottom-hua" >
      					<?php for ($i=0; $i<=6; $i++):?>
	                    	<a href="#" class="bh-yw-bn" val='<?php echo date('Y-m-d',strtotime("+{$i}day"))?>'>
	                    		<span>￥<?php echo $model->minPrice(date('Y-m-d',strtotime("+{$i}day")),'price_dealer')?></span>
	                    		<?php echo date('m-d',strtotime("+{$i}day"))?><?php echo CUtilHelper::date()->chineseWeek(strtotime("+{$i}day"))?>
	                    	</a>
                    	<?php endfor;;?>
                    </p>
                    <?php endif;?>
                    <div class="bh-space"></div>
                 	 <div class="bh-ly-yw-jipiao-hangkong">
                    	舱位：<?php echo $form->dropDownList($model,'accommodation',Yii::app()->enum->options('goods.flightAccommodation'),array('class'=>'bh-ly-yw-biao'))?>
                	</div>
                <?php $this->endWidget();?>
                <table width="710" height="157" class="bh-pj-border">
                	<?php if (!empty($_GET[get_class($model)])):?>
                	<?php foreach ($data->getData() as $one):?>
                	<tr class="bh-ly-yw-jipiao-dianji">
                    	<td width="156">
                    		<span class="bh-ly-yw-dong">
                    			<?php echo $one->img(19,19)?>
                    			<?php echo CHtml::value($one, 'profile.airlines')?>
                    		</span>
                    		 机型：<?php echo CHtml::value($one, 'profile.aircraft_type')?>
                    		 |<?php echo Yii::app()->enum->lookUp('goods.flightAccommodation',CHtml::value($one, 'profile.accommodation'))?>
                    	</td>
                        <td width="180" class="bh-ly-yw-jipiao-qifei">
                        	<span>起飞：<b class="font_cr0"><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.departure_time'),'H:i')?></b> <?php echo CHtml::value($one, 'profile.departure_airport')?></span>
                        	 降落：<b class="font_cr0"><?php echo CUtilHelper::date()->changeFormat(CHtml::value($one, 'profile.landing_time'),'H:i')?></b> <?php echo CHtml::value($one, 'profile.landing_airport')?>
                       </td>
                        <td width="90" class="bh-ly-yw-jipiao-jiage"><b class="bh-mrt5 bh-font18">￥<?php echo $one->timePriceObjAttr('price_dealer',$time)?></b></td>
                        <?php if (!Yii::app()->adminUser->isDealer()):?>
                        <td width="107"><input type="submit" value="立即预定" class="bh-ly-yw-center-jjingqu-sub bh-href" href='<?php echo $this->createUrl('ticketWrite',array('id'=>$one->id))?>'/></td>
                    	<?php endif;?>
                    </tr>
    				<?php endforeach;?>
    				<?php endif;?>
                </table>
                <div class="bh-c-shuizi1-c-yy bh-mLeft20">
    				<?php $this->widget('LyLinkPager',array(
    					'pages' => $data->pagination,
    				))?>
    			</div>
              	</div>
            </div>
            
            <!-- ***************右侧*************** -->
            <div class="bh-ly-yw-jipiao-center-xiaright bh-fl bh-fr">
            	<div class="bh-ly-yw-jipiao-center-xiaright-top">
            	<!-- ***************热门机票*************** -->
                    <?php $this->widget('lib.ext.data.DataWidget',array(
                    	'model' => 'Ticket',
                    	'data' => array(
                    		'title' => '热门机票',
                    	),
                    	'criteria' => array(
                    		'order' => 'is_recommend DESC',
                    	    'scopes' => 'listing',
                    		'limit' => '10'
                    	),
                    	'view' => 'application.views.partials.ticket.right_lattice'
                    ));?>
                </div>
                <!-- ***************机票点评*************** -->
                <div class="bh-ly-yw-jipiao-center-xiaright-bottom bh-mtop10">
                	<?php $this->widget('lib.ext.data.DataWidget',array(
                    	'model' => 'Ticket',
                    	'data' => array(
                    		'title' => '机票点评'
                    	),
                    	'criteria' => array(
                    		'limit' => '10'
                    	),
                    	'view' => 'application.views.partials.ticket.review'
                    ));?>
            	</div>
        	</div>
        <div class="bh-clear"></div>
    </div>
    </div> 
     
</div>
<script>
$.tabable({
	triggers: '#manner > li',
	contents: '#ticket-content > div',
	hoverClass: 'hover'
});
$('#manner li').click(function () {
	index = $(this).attr('index');
	$('#index-val').val(index);
	$('#list-time li').removeClass('hover');
	time = '';
	if(index == 0) { // 单程
		$('#oneWay').show();
		$('#return').hide();
		time = $('#oneWay-time').val();
	} else { // 往返
		$('#return').show();
		$('#oneWay').hide();
		time = $('#return-time').val();
	}
	$('#list-time li[val='+time+']').addClass('hover');
});

$('.list-time li').click(function() {
	val = $('#manner').val();
	time = $(this).attr('val');
	if($('#manner-val').val() == 'oneWay') {
		$('#oneWay-time').val(time);
	} else {
		index = $('#manner li[class=hover]').attr('index');
		if(index == 0) { // 单程
			$('#oneWay-time').val(time);
		} else { // 往返
			$('#return-time').val(time);
		}
	}
	$('#ticket-form').submit();
});

$('#manner li').removeClass('hover');
$('#manner li[index='+$('#index-val').val()+']').addClass('hover');
$('#manner li[index='+$('#index-val').val()+']').click();
</script>
